package com.springboot.mongodb.impl;

import com.springboot.mongodb.dao.LabelDao;
import com.springboot.mongodb.dao.UserDao;
import com.springboot.mongodb.model.AddLabelDTO;
import com.springboot.mongodb.model.Label;
import com.springboot.mongodb.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @ClassName springboot_mongodb - LabelServiceImpl
 * @Description [此类用于: ]
 * @Author liming-jybdd@foxmail.com
 * @Date 2021/9/2617:13
 * @Version 1.0
 **/
@Service
public class LabelServiceImpl {

    @Autowired
    private LabelDao labelDao;

    @Autowired
    private UserDao userDao;

    public List<Label> findAll(){
        return labelDao.findAll();
    }

    public List<User> findAllUser(){
        return userDao.findAll();
    }

    public void saveLabel(AddLabelDTO addLabelDTO){
        Label label = new Label();
        label.setHtmId(addLabelDTO.getHtmId());
        label.setUserId(addLabelDTO.getUserId());
        label.setBreadcrumbs(addLabelDTO.getBreadcrumbs());
        labelDao.insert(label);
    }

}